package vn.gamesv.stores.adapter;

import java.util.List;

import vn.gamesv.stores.R;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

public class ListStoryAdapter extends BaseAdapter{
	private Context mContext;
	private List<ListItemObject> mItemObjects;
	
	public ListStoryAdapter(Context context, List<ListItemObject> list){
		mContext = context;
		mItemObjects = list;
	}

	@Override
	public int getCount() {
		return mItemObjects.size();
	}

	@Override
	public Object getItem(int position) {
		return mItemObjects.get(position);
	}

	@Override
	public long getItemId(int position) {
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		ListItemObject entry = mItemObjects.get(position);

		// inflating list view layout if null
		if(convertView == null) {
			LayoutInflater inflater = LayoutInflater.from(mContext);
			convertView = inflater.inflate(R.layout.list_item_detail, null);
		}

		// set title
		TextView tvTitle = (TextView)convertView.findViewById(R.id.title_list_item);
		tvTitle.setText(entry.getmTitle());

		// set view number
		TextView tvViewNumber = (TextView)convertView.findViewById(R.id.view_number);
		tvViewNumber.setText(entry.getmViewNumber());

		return convertView;
	}

}
